package com.samphanie.auiu.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
import java.io.Serializable

/**
 * @author ZSY
 */
data class HomeModel(
    val bannerList: List<HomeBanner>?,
    val subCategoryList: List<SubCategory>?,
    val goodsList: List<GoodsModel>?,
) : Serializable

data class TabCategory(
    val id: String,
    val name: String,
    val goodsCount: Int
) : Serializable

data class HomeBanner(
    val id: String,
    val sticky: Int,
    val type: Int,
    val title: String,
    val subTitle: String,
    val url: String,
    val cover: String,
    val createTime: String
) : Serializable {
    companion object {
        const val TYPE_GOODS = 0
        const val TYPE_RECOMMEND = "recommend"
    }
}

data class SubCategory(
    val id: String,
    val groupName: String,
    val cateId: String,
    val subCategoryName: String,
    val subCategoryIcon: String,
    val showType: Int
) : Serializable

@Parcelize
data class GoodsModel(
    val id: String,
    val cateId: String,
    val marketPrice: String,
    val groupPrice: String,
    val hot: Boolean,
    val completedNumText: String,
    val goodsName: String,
    val tags: String,
    val joinedAvatars: List<String>?,
    val sliderImage: String,
    val sliderImages: List<SliderImage>?,
    val createTime: String
) : Serializable, Parcelable

@Parcelize
data class SliderImage(
    val type: Int,
    val url: String
) : Serializable, Parcelable

data class GoodsList(val totalCount: Int, val list: List<GoodsModel>) : Serializable

fun selectPrice(marketPrice: String?, groupPrice: String?): String {
    if (!marketPrice.isNullOrBlank()) return marketPrice
    if (!groupPrice.isNullOrBlank()) return "￥$groupPrice"
    return ""
}